Skip to content

Updated ocr3 Metadata type to include Encoding and Decoding #1160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

silaslenihan
Copy link
Contributor

@silaslenihan silaslenihan commented Apr 25, 2025

return buf.Bytes(), nil
}

const MetadataLen = 1 + 32 + 4 + 4 + 4 + 32 + 10 + 20 + 2 // =109
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe worth repeating these details here 🤷

Suggested change
const MetadataLen = 1 + 32 + 4 + 4 + 4 + 32 + 10 + 20 + 2 // =109
// 1B Version, 32B ExecutionID, 4B Timestamp, 4B DONID, 4B DONConfigVersion,
// 32B WorkflowID, 10B WorkflowName, 20B WorkflowOwner, 2B ReportID
const MetadataLen = 1 + 32 + 4 + 4 + 4 + 32 + 10 + 20 + 2 // =109

}

// appendAttrsRequired appends required attributes to the attribute key-value list
func (e *protoEmitter) appendAttrsRequired(ctx context.Context, m proto.Message, attrKVs []any) []any {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Context is unused

Suggested change
func (e *protoEmitter) appendAttrsRequired(ctx context.Context, m proto.Message, attrKVs []any) []any {
func (e *protoEmitter) appendAttrsRequired(m proto.Message, attrKVs []any) []any {

Comment on lines +93 to +94
attrKVs = appendRequiredAttrEntity(m, attrKVs)
attrKVs = appendRequiredAttrDomain(m, attrKVs)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we align with the build in append func, by passing attrKVs as the first argument?

Suggested change
attrKVs = appendRequiredAttrEntity(m, attrKVs)
attrKVs = appendRequiredAttrDomain(m, attrKVs)
attrKVs = appendRequiredAttrEntity(attrKVs, m)
attrKVs = appendRequiredAttrDomain(attrKVs, m)

Comment on lines +69 to +70
// Needs to be an URI (Beholder requirement)
val := toSchemaPath(m, basePath)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to be doing this for the caller? This is the only use of m and basePath, so we could just accept the val as a parameter, which is more flexible/reusable.

Comment on lines +92 to +96
for i := 0; i < len(attrKVs); i += 2 {
if attrKVs[i] == key {
return attrKVs
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make some kind of helper for this repeated block:

Suggested change
for i := 0; i < len(attrKVs); i += 2 {
if attrKVs[i] == key {
return attrKVs
}
}
if containsKey(attrKVs, key) {
return attrKVs
}
func containsKey(attrKVs []any, key string) bool {
	for i := 0; i < len(attrKVs); i += 2 {
		if attrKVs[i] == key {
			return true
		}
	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants